// bitmap.dll

#ifdef BITMAP_EXPORTS
#define BITMAP_API __declspec(dllexport)
#else
#define BITMAP_API __declspec(dllimport)
#endif


// CONSTANTS ////////////////////////////////////////////////////////////

#define BITMAP_RGB	0
#define BITMAP_IDX	1


// TYPES ////////////////////////////////////////////////////////////////

typedef unsigned char class_t;
typedef unsigned char count_t;


// STRUCTURES ///////////////////////////////////////////////////////////

// FILEHEADER - a file header structure for a temp file

typedef struct tagFileHeader {
	class_t clsid;
	size_t  width;
	size_t  height;
	count_t clrnum;
	RGBQUAD colors[256];
} FILEHEADER, *PFILEHEADER;

// IMAGE - mapping a temp file

typedef struct tagImage {
	FILEHEADER header;
	PBYTE data;
} IMAGE, *PIMAGE;

typedef RGBQUAD* PRGBQUAD;

// FUNCTIONS ////////////////////////////////////////////////////////////

BITMAP_API BOOL BITMAP_LoadFile	(HANDLE, PIMAGE);			// Load a bitmap file
BITMAP_API BOOL BITMAP_SaveFile	(HANDLE, PIMAGE);			// Save a bitmap file

BITMAP_API BOOL BITMAP_24TO8	(PIMAGE, PIMAGE, PRGBQUAD);	// Convert 24bit image to 8bit image
BITMAP_API BOOL BITMAP_24TO8G	(PIMAGE, PIMAGE);			// Convert 24bit image to 8bit gray image
BITMAP_API BOOL BITMAP_24TO4	(PIMAGE, PIMAGE, PRGBQUAD);	// Convert 24bit image to 4bit image
BITMAP_API BOOL BITMAP_24TO1	(PIMAGE, PIMAGE, int);		// Convert 24bit image to 1bit image

BITMAP_API BOOL BITMAP_8TO24	(PIMAGE, PIMAGE);			// Convert 8bit image to 24bit image
BITMAP_API BOOL BITMAP_8TO4		(PIMAGE, PIMAGE, PRGBQUAD);	// Convert 8bit image to 4bit image
BITMAP_API BOOL BITMAP_8TO1		(PIMAGE, PIMAGE, int);		// Convert 8bit image to 1bit image

BITMAP_API BOOL BITMAP_4TO24	(PIMAGE, PIMAGE);			// Convert 4bit image to 24bit image
BITMAP_API BOOL BITMAP_4TO8		(PIMAGE, PIMAGE, PRGBQUAD);	// Convert 4bit image to 8bit image
BITMAP_API BOOL BITMAP_4TO1		(PIMAGE, PIMAGE, int);		// Convert 4bit image to 1bit image

BITMAP_API BOOL BITMAP_1TO24	(PIMAGE, PIMAGE);			// Convert 1bit image to 24bit image
BITMAP_API BOOL BITMAP_1TO8		(PIMAGE, PIMAGE);			// Convert 1bit image to 8bit image
BITMAP_API BOOL BITMAP_1TO4		(PIMAGE, PIMAGE);			// Convert 1bit image to 4bit image

BITMAP_API BOOL BITMAP_P8TO4	(PRGBQUAD, PRGBQUAD);		// Convert 8bit palette to 4bit palette
BITMAP_API BOOL BITMAP_P8TO1	(PRGBQUAD, PRGBQUAD);		// Convert 8bit palette to 1bit palette

BITMAP_API BOOL BITMAP_P4TO8	(PRGBQUAD, PRGBQUAD);		// Convert 4bit palette to 8bit palette
BITMAP_API BOOL BITMAP_P4TO1	(PRGBQUAD, PRGBQUAD);		// Convert 4bit palette to 1bit palette

BITMAP_API BOOL BITMAP_P1TO8	(PRGBQUAD, PRGBQUAD);		// Convert 1bit palette to 8bit palette
BITMAP_API BOOL BITMAP_P1TO4	(PRGBQUAD, PRGBQUAD);		// Convert 1bit palette to 4bit palette